#ifndef CAMERA_VIRTUAL_H
#define CAMERA_VIRTUAL_H
#include "../Base/RealtimeCamera.hpp"
#include <filesystem>
#include <mutex>
#include <thread>

class VirtualConfig;

/**
 * @class VirtualCamera
 * @brief 虚拟相机
 * @note 允许获取的最大图片大小为1080P RGB
 */
class VirtualCamera : public RealtimeCamera {
private:
  friend class VirtualConfig;
  VirtualConfig *config;
  std::mutex imgDataMux;
  std::unique_ptr<unsigned char, void (*)(unsigned char *)> imgData; // 图片数据
  ImgInf inf;
  std::string UUID;
  std::jthread workThread;
  std::filesystem::path imgPath;

public:
  /**
   * @brief 构造函数
   *
   * @param UUID 相机UUID
   */
  VirtualCamera(const std::string &UUID);
  /**
   * @brief 析构函数
   */
  virtual ~VirtualCamera();
  /**
   * @brief 获取设备UUID
   */
  virtual std::string GetUUID() override final;
  /**
   * @brief 获取拍摄状态
   *
   * @return 拍摄状态
   */
  virtual bool ShotStatus() override final;
  /**
   * @brief 获取相机设置代理
   *
   * @return 设置代理
   */
  virtual BaseConfig *Config() override final;
  /**
   * @brief 最大单一图片大小
   * @return 图像大小（字节）
   */
  virtual long MaxSingleImgSize() override final;
  /**
   * @brief 帧率
   *
   * @return 当前帧率
   */
  virtual float FPS() override final;
  /**
   * @brief 开始拍摄
   */
  virtual void StartShot() override final;
  /**
   * @brief 停止拍摄
   */
  virtual void StopShot() override final;
  /**
   * @brief 拍摄图像类型
   */
  virtual BaseCamera::ImgInf ShotImageType() override final;
};

#endif
